
<template>
  <view>
    
  
  <view class="Box" v-if="carlist.length!=0">
    
    <!-- 收货地址 -->
    <my-address></my-address>
    
    <!-- 购物车商品列表的标题区域 -->
    <view class="cart-title">
      <uni-icons type="shop" size="20"></uni-icons>
      <text class="cart-title-text">购物车</text>
    </view>
    
    
    <!-- 商品列表区域 -->
      <block v-for="(goods, i) in carlist" :key="i">
        <my-goodsList :goods="goods" :show-radio="true" @radio-change="radioHandler" @num-change="numHandler" :isShowFlag="true"></my-goodsList>
      </block>      
    
    
    <my-settle class="settle"></my-settle>
    
  </view>
  
    <view class="empty-cart" v-else>
      <image src="/static/cart_empty@2x.png" class="empty-img"></image>
      <text class="tip-text">空空如也~</text>
    </view>
    
  </view>
</template>

<script>
  import badge from "@/mixins/tabbar.js"
  import {mapState,mapMutations} from 'vuex'
  
  export default {
    mixins:[badge],//购物车徽标
    computed:{
      ...mapState('my_car',['carlist'])
    },
    data() {
      return {
        options:[{
            text:"删除",
            style:{backgroundColor:'#dd524d'}
          }]
      };
    },
    
    methods:{
      ...mapMutations('my_car',['checkStatus','changeNum']),
      
      radioHandler(e){
        this.checkStatus(e)
      },
      
      numHandler(e){
        this.changeNum(e)
      },
      
      swipeActionClickHandler(e){
        console.log(e)
      },
      
      swipeChange(e,index){
        console.log('当前状态：'+ e +'，下标：' + index)
      },
      
      
    }
  }
</script>

<style lang="scss">
.Box{
  padding-bottom: 50px;
  .cart-title {
    height: 40px;
    display: flex;
    align-items: center;
    font-size: 14px;
    padding-left: 5px;
    border-bottom: 1px solid #efefef;
    .cart-title-text {
      margin-left: 10px;
    }
  }
  .settle{
    // border: 1px solid red;
    position: fixed;
    bottom: 0px;
  }
  
}

.empty-cart {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 150px;

  .empty-img {
    width: 90px;
    height: 90px;
  }

  .tip-text {
    font-size: 12px;
    color: gray;
    margin-top: 15px;
  }
}

  
</style>
